package com.example.demo.controller;


import com.example.demo.dto.ResultJson;
import com.example.demo.entity.Cangku;
import com.example.demo.entity.Rukujilu;
import com.example.demo.entity.User;
import com.example.demo.mapper.Cangku_Mapper;
import com.example.demo.mapper.Danweixinxi_Mapper;
import com.example.demo.mapper.Rukujilu_Mapper;
import com.example.demo.utils.DateUtils;
import com.example.demo.utils.MD5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("Rukujilu")
public class Rukujilu_Controller extends BasicController<Rukujilu> {
	@Autowired
	Rukujilu_Mapper mapper;
	@Autowired
	Cangku_Mapper cangku_mapper;
	@Autowired
	Danweixinxi_Mapper danweixinxi_mapper;


	@Override
	public ResultJson insert(Rukujilu r) {
		int shuliang = r.getCaozuoshuliang();
		int id = r.getChanpinid();
		cangku_mapper.tianjiashuliang(id,shuliang);
		r.setRukutime(DateUtils.getNowTime());

		danweixinxi_mapper.addone2();

		return super.insert(r);
	}

	@RequestMapping("/update")
	public ResultJson update(Rukujilu r){
		r.setRukutime(DateUtils.getNowTime());
		super.update(r);
		return new ResultJson(1);
	}



}
